package yxy.game.pm2.command.chibi;

import yxy.cherry.game.base.message.MessageEmitterHandler;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.game.pm2.Result;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.ChibiMessage;
import yxy.game.pm2.module.chibi.ChibiHandle;

/** 火烧赤壁 火烧赤壁主界面 */
@MessageType(proto = Command.ChibiMain, classtype = ChibiMessage.ChibiMainRequest.class)
public class CMD_ChibiMain extends Command<ChibiMessage.ChibiMainRequest> {

	@Override
	public void execute(MessageSource messageSource, ChibiMessage.ChibiMainRequest request) {
		String playerCode = messageSource.getTag();

		ChibiMessage.ChibiMainResponse.Builder response = ChibiMessage.ChibiMainResponse.newBuilder();

		Result result = new ChibiHandle().mainUI(playerCode, response);

		send(messageSource, response, result);
	}

	private void send(MessageSource messageSource, ChibiMessage.ChibiMainResponse.Builder response, Result result) {
		response.setResult(result.packResult());
		MessageEmitterHandler.getInstance().send(messageSource, response.build());
	}
}